<template>
  <div>
   <div id="person">
      <!-- 头像 -->
      <div class="photo">
        <img v-lazy="$store.getters.avatar" alt="avatar">
      </div>
      <div class="p-info">
        <!-- 昵称 -->
        <p id="name">{{nickName}}</p>
        <!-- 会员类型 -->
        <p class="summary" v-if="status === 'not_apply'">
          会员类型：<em>{{curEnterType}}</em>
           <!-- 未申请状态 -->
          <span class="desc" @click="onEnterShop('supplier')">
            升级供应商
          </span>
        </p>
        <!-- 未支付状态 -->
        <div>
          <p v-if="status == 'failed' || status == 'success' || status == 'review'">
            申请类型：<span class="txt-main">{{enterTypeName}}</span>
          </p>
          <p v-if="status === 'failed'">
            状态：<span class="txt-main">审核不通过</span>
          </p>
          <p v-if="status === 'success'">
            状态：<span class="txt-success">审核通过</span>
          </p>
          <p v-if="status === 'review'">
            状态：<span class="txt-in">审核中</span>
          </p>
        </div>
        <!-- 审核通过状态 -->
        <div class="" v-if="status === 'failed'">
          <p>
            原因：<span class="txt-main">{{cause || ''}}</span>
          </p>
        </div>
      </div>
    </div>

    <!-- 申请类型，只有未申请的才显示 -->
    <div class="e-body" v-if="status === 'not_apply'">
      <div class="e-b">
        普通会员可以通过增值服务，升级成为供应商，供应商可以开通店铺，发布商品等权益！
      </div>
      <!-- <section>请选择升级类型</section>
      <div class="e-b">
        <div class="e-b-r">
          <div class="e-b-r-col">
            <div class="tit">采购商</div>
            <em>权益</em>
            <p>
              <ul>
                <li>商家后台管理</li>
                <li>提供信息推广渠道</li>
                <li>商家店铺营销</li>
                <li>...</li>
              </ul>
            </p>
            <div class="button" @click="onEnterShop('purchaser')">立即入驻</div>
          </div>
          <div class="e-b-r-col">
            <div class="tit">供应商</div>
            <em>权益</em>
            <p>
              <ul>
                <li>商家后台管理</li>
                <li>提供信息推广渠道</li>
                <li>商家店铺营销</li>
                <li>...</li>
              </ul>
            </p>
            <div class="button" @click="onEnterShop('supplier')">立即入驻</div>
          </div>
          <div style="clear:both"></div>
        </div>
      </div> -->
    </div>
  
    <!-- 商家信息，只有申请过的显示采购商商家信息 -->
    <div class="info-b" v-if="status !== 'not_apply' && enterType == 'purchaser'">
      <span class="title">公司档案</span>
      <span class="modyfi-btn" @click="onEditInfo">修改</span>
      <div style="clear:both;"></div>
      <div class="info-b-c clearfix">
        <div class="info-b-c-col">
          <div class="info-row">公司名称:
            <span>{{enterInfo.company}}</span>
          </div>
          <div class="info-row">业务类型:
            <span>{{enterInfo.enterpriseType}}</span>
          </div>
          <div class="info-row">主营行业:
            <span>{{enterInfo.mainIndustry}}</span>
          </div>
          <div class="info-row">主营产品:
            <span>{{enterInfo.mainProducts}}</span>
          </div>
          <div class="info-row">销售渠道网址:
            <span>{{enterInfo.mainSalesChannels}}</span>
          </div>
          <div class="info-row">年销售额:
            <span>{{enterInfo.yearSales}}</span>
          </div>
          <div class="info-row">业务联系人:
            <span>{{enterInfo.businessContacts}}</span>
          </div>
        </div>
        <div class="info-b-c-col">
          <div class="info-row">营业执照号:
            <span>{{enterInfo.licenseNumber}}</span>
          </div>
          <div class="info-row">员工人数:
            <span>{{enterInfo.employeesNum}}</span>
          </div>
          <div class="info-row">产品风格:
            <span>{{enterInfo.productStyle}}</span>
          </div>
          <div class="info-row">主要客户群体:
            <span>{{enterInfo.mainCustomerGroups}}</span>
          </div>
          <div class="info-row">所在地:
            <span>{{enterInfo.area}}{{enterInfo.detailAddress}}</span>
          </div>
          <div class="info-row">月销售额:
            <span>{{enterInfo.monthSales}}</span>
          </div>
          <div class="info-row">业务联系人电话:
            <span>{{enterInfo.contactPhone}}</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 商家信息，只有申请过的显示供应商商家信息 -->
    <div class="info-b" v-if="status !== 'not_apply' && enterType == 'supplier'">
      <span class="title">公司档案</span>
      <span class="modyfi-btn" @click="onEditInfo">修改</span>
      <div style="clear:both;"></div>
      <div class="info-b-c clearfix">
        <div class="info-b-c-col">
          <div class="info-row">公司名称:
            <span>{{enterInfo.company}}</span>
          </div>
          <div class="info-row">企业类型:
            <span>{{enterInfo.enterpriseType}}</span>
          </div>
          <div class="info-row">主营行业:
            <span>{{enterInfo.mainIndustry}}</span>
          </div>
          <div class="info-row">主营产品:
            <span>{{enterInfo.mainProducts}}</span>
          </div>
          <div class="info-row">年出口额:
            <span>{{enterInfo.yearExportNum}}</span>
          </div>
          <div class="info-row">年营业额:
            <span>{{enterInfo.yearSales}}</span>
          </div>
          <div class="info-row">业务联系人:
            <span>{{enterInfo.businessContacts}}</span>
          </div>
          <div class="info-row">农商行商户号:
            <span>{{enterInfo.subMerchantId}}</span>
          </div>
          <div class="info-row">店铺介绍:
            <span>{{enterInfo.shopIntroduction}}</span>
          </div>
        </div>
        <div class="info-b-c-col">
          <div class="info-row">营业执照号:
            <span>{{enterInfo.licenseNumber}}</span>
          </div>
          <div class="info-row">员工人数:
            <span>{{enterInfo.employeesNum}}</span>
          </div>
          <div class="info-row">产品风格:
            <span>{{enterInfo.productStyle}}</span>
          </div>
          <div class="info-row">主要客户群体:
            <span>{{enterInfo.mainCustomerGroups}}</span>
          </div>
          <div class="info-row">所在地:
            <span>{{enterInfo.area}}{{enterInfo.detailAddress}}</span>
          </div>
          <div class="info-row">月产量:
            <span>{{enterInfo.monthProduction}}</span>
          </div>
          <div class="info-row">业务联系人电话:
            <span>{{enterInfo.contactPhone}}</span>
          </div>
        </div>
        <div class="fail-img" v-show="status === 'failed'">
          <img src="../../assets/failImg.png">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { mapGetters, mapActions, mapMutations } from 'vuex'

  const NORMAL_TYPE = '普通会员'

  export default {
    beforeRouteEnter(to, from, next) {
      next(vm => {
        // 请求基本信息
        vm.fetchApplyRoleInfo({
          token: vm.token
        })
      })
    },
    methods: {
      ...mapActions(['fetchApplyRoleInfo']),
      ...mapMutations(['updataApplyType']),
      // 立即入驻，分为采购商和供应商
      onEnterShop(type) {
        this.$router.push(`/my/extra/application?type=${type}`)
      },
      // 修改资料信息
      onEditInfo() {
        this.$router.push(`/my/extra/application?edit=1&id=${this.enterInfo.id}&type=${this.enterType}`)
      },
      // 去支付
      onGoPayment(pay) {
        const payQuery = pay ? '&status=pay' : ''
        this.$router.push(`/my/extra/pay?type=${this.enterType}&id=${this.enterInfo.id}${payQuery}`)
      }
    },
    computed: {
      ...mapGetters(['token', 'status', 'cause', 'enterInfo', 'enterTypeName', 'enterType', 'nickName', 'enterTime']),
      // 当前会员类型
      curEnterType() {
        return (this.status == 'not_pay' || this.status == 'not_apply') ? NORMAL_TYPE : this.enterTypeName
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import '../../scss/_var.scss';
  .fail-img {
    position: absolute;
    right: 60px;
    width: 90px;
    height: 80px;
    z-index: 2;
  }
  .txt-main {
    color: #F00384;
  }
  .txt-success {
    color: #17a93c;
  }
  .txt-in {
    color: #f5a96f;
  }
  #person {
    background-color: #fff;
    min-height: 140px;
    width: 1080px;
    .photo {
      width: 100px;
      height: 100px;
      float: left;
      margin: 20px 40px;
      img {
        border-radius: 50%;
      }
    }
    .p-info {
      display: inline-block;
      padding: 20px 0;
      p{
        line-height: 30px;
        font-size: 14px;
      }
      em{
        color: #F00384;
      }
      #name {
        color: black;
        font-size: 18px;
      }
      .summary {
        .desc {
          border: 1px solid;
          height: 36px;
          line-height: 36px;
          padding: 0 10px;
          color: $color-white;
          background-color: #F00384;
          margin-left: 18px;
          cursor: pointer;
        }
      }
    }
  }
  .e-body{
    margin-top: 10px;
    background-color: $color-white;
    padding: 25px;
    // height: 380px;
    section{
      padding-top: 20px;
      padding-left: 26px;
      padding-bottom: 29px;
      font-size: 16px;
      color: $color-dark;
    }
    .e-b{
      &-r{
        &-col{
          float:left;
          width: 220px;
          height: 280px;
          border: 1px solid $color-gray;
          margin-left:140px;
          .tit{
            height: 50px;
            line-height: 50px;
            text-align: center;
            border-bottom: 1px solid $color-gray;
            font-size: 16px;
            color: $color-black;
          }
          em{
            display: block;
            margin-left: 22px;
            margin-top: 27px;
            color: $color-gray;
            font-size: 14px;
            
          }
          p{
            margin-left: 74px;
            margin-top: 20px;
            ul{
              list-style-type:square;
              color: $color-dark;
            }
          }
        }
      }
    }
  }
  .button{
    height: 30px;
    line-height: 30px;
    width: 150px;
    border: 1px solid;
    color: $color-main;
    text-align: center;
    margin:30px auto;
    cursor: pointer;
  }
  .info-b{
    width: 100%;
    padding: 20px;
    margin-top: 19px;
    background-color: $color-white;
    .title{
      color: $color-dark;
    }
    .modyfi-btn{
      height: 28px;
      border: 1px solid;
      color: $color-main;
      line-height: 28px;
      text-align: center;
      padding: 0 20px;
      float: right;
      cursor: pointer;
    }
    &-c{
      padding: 25px 80px;
      border: 1px solid #ddd;
      margin-top: 14px;
      &-col{
        width: 50%;
        margin: auto;
        float: left;
        text-align: left;
        .info-row{
          margin-bottom: 26px;
          color: $color-gray;
          span {
            color: $color-dark;
          }
          &:last-of-type {
            margin-bottom: 0;
          }
        }
      }
    }
  }
  .goBtn{
    background-color: #F00384;
    width: 120px;
    height: 26px;
    line-height: 26px;
    font-size: 14px;
    color: #fff;
    margin-left: 72px;
  }
</style>